package com.cxh.base;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.cxh.service.*;

/**
 * 类说明：父级Controller
 * @author  ChenXH
 * @date  2018年7月22日
 */
@Controller
public class BaseController {
	/**存放所有 Service便于子类调用*/
	@Autowired
	protected SysUserRoleService sysUserRoleService;
	@Autowired
	protected SysUserService sysUserService;
	@Autowired
	protected SysMenuService sysMenuService;
	@Autowired
	protected SysRoleMenuService sysRoleMenuService;
	@Autowired
	protected SysRoleService sysRoleService;
	@Autowired
	protected CarDiscountService carDiscountService;
	@Autowired
	protected CarAgencyRobotService carAgencyRobotService;
	@Autowired
	protected CarLoanService carLoanService;
	@Autowired
	protected CarCategoryService carCategoryService;
	@Autowired
	protected SysUserRobotService sysUserRobotService;
	
	
	
	
	@Autowired
	protected CarSeriesService carSeriesService;
	@Autowired
	protected CarTypeService carTypeService;
	@Autowired
	protected CarClassifyService carClassifyService;
	@Autowired
	protected CarModelService carModelService;
	@Autowired
	protected CarDetailBaseInfoService carDetailBaseInfoService;
	@Autowired
	protected CarDetailBodyService carDetailBodyService;
	@Autowired
	protected CarDetailChangeSpeedCaseService carDetailChangeSpeedCaseService;
	@Autowired
	protected CarDetailChassisTurnService carDetailChassisTurnService;
	@Autowired
	protected CarDetailConditionRefrigeratorService carDetailConditionRefrigeratorService;
	@Autowired
	protected CarDetailControlConfigService carDetailControlConfigService;
	@Autowired
	protected CarDetailEngineService carDetailEngineService;
	@Autowired
	protected CarDetailGlassMirrorService carDetailGlassMirrorService;
	@Autowired
	protected CarDetailInConfigService carDetailInConfigService;
	@Autowired
	protected CarDetailHighTechService carDetailHighTechService;
	@Autowired
	protected CarDetailMediaConfigService carDetailMediaConfigService;
	@Autowired
	protected CarDetailLightConfigService carDetailLightConfigService;
	@Autowired
	protected CarDetailSafetyEquipmentService carDetailSafetyEquipmentService;
	@Autowired
	protected CarDetailSeatConfigService carDetailSeatConfigService;
	@Autowired
	protected CarDetailOutConfigService carDetailOutConfigService;
	@Autowired
	protected CarDetailWheelBrakeService carDetailWheelBrakeService;
	@Autowired
	protected CarCategoryIntroduceService carCategoryIntroduceService;
	@Autowired
	protected CarCompetitiveService carCompetitiveService;
	@Autowired
	protected CarCompetitiveDetailService carCompetitiveDetailService;
	@Autowired
	protected CarActivityService carActivityService;
	@Autowired
	protected CarModelOthernameService carModelOthernameService;
	@Autowired
	protected CarQuestionService carQuestionService;
	@Autowired
	protected CarKnowledgeService carKnowledgeService;
	@Autowired
	protected CarModeldataMenuService carModeldataMenuService;
	@Autowired
	protected CarDiscountDetailService carDiscountDetailService;
	
	@Autowired
	protected RobotInfoService robotInfoService;
	@Autowired
	protected SkillsOptionService skillsOptionService;
	@Autowired
	protected SysVarsService sysVarsService;
	@Autowired
	protected CmdCollectionService cmdCollectionService;
	@Autowired
	protected SkillsOptionCmdService skillsOptionCmdService;
	@Autowired
	protected SoundQuService soundQuService;
	@Autowired
	protected SoundQuAnService soundQuAnService;
	@Autowired
	protected RobotMapLibService robotMapLibService;
	
	public static  void ajaxOutput(HttpServletResponse response,String outputString){
		response.setContentType("text/html; charset=utf-8");
		try{
			System.out.println("---------------------------" + outputString+ "--------------------------------------------");
			response.getWriter().write(outputString);
			response.getWriter().flush();
			response.getWriter().close();
		} catch (IOException e){
			e.printStackTrace();
		}
	}
	
	/**
     * 四舍五入
     * @param d
     * @return
     */
    public static double formatDouble1(double d) {
        return (double)Math.round(d);
    }
    /**
     * 保留两位小数，四舍五入的一个老土的方法
     * @param d
     * @return
     */
    public static double formatDouble2(double d) {
        return (double)Math.round(d*100)/100;
    }
}
